<template>
    <div class="leftmenu-box">
        <!-- 左侧菜单上面部分 -->
        <div class="left-menu-top">
            <MenuFile :menuData="menuData"/>
        </div>
        <!-- 左侧菜单下面广告位 -->
        <div class="left-menu-bottom" v-if='data'>
            <div class="img-box">
                <img src="/static/img/common/ad.png" alt="">
            </div>
            <div class="info-box">
                <p class="tips">个人空间使用情况</p>
                <Progress :width='width'/>
                <p class="info">{{data.used}}/{{data.total}}</p>
            </div>
        </div>
    </div>
</template>
<script>
import MenuFile from './menuFile'
import MenuUser from './menuUser'
import Progress from './progress'
export default {
    data () {
        return {
            menuData:[],
            width:1, //进度条终止位置即使用比例
            data:'',
            davMenuData:[ //文件管理左侧菜单数据
                {icon:'/static/img/common/wj.png',icon_active:'/static/img/common/wj-active.png',name:'公司文件',status:1,path:'/layout',type:2},
                {icon:'/static/img/common/gr.png',icon_active:'/static/img/common/gr-active.png',name:'个人文件',status:0,path:'/personFile',type:1},
                {icon:'/static/img/common/hs.png',icon_active:'/static/img/common/hs-active.png',name:'回收站',status:0,path:'/recycleBin',type:3},
            ],
            messageData:[ //消息列表左侧菜单数据
                 {icon:'/static/img/common/message.png',icon_active:'/static/img/common/message.png',name:'消息列表',status:1,path:''}
            ],
            infoData:[ //账号管理左侧菜单数据
                {icon:'/static/img/common/wj-active.png',icon_active:'/static/img/common/wj-active.png',name:'账号管理',status:1,path:''}
            ]
        }
    },
    components: {
        MenuFile,
        MenuUser,
        Progress
    },
    computed: {
      getTopNavTab(){
          return this.$store.getters.getTopNavTab;
      }  
    },
    watch: {
        getTopNavTab(news,olds){
            if(news == '消息列表'){
                this.menuData = this.messageData;
            }else if(news == '文件管理'){
                this.menuData = this.davMenuData;
            }else if(news == '账号管理'){
                 this.menuData = this.infoData;
            }
        }
    },
    mounted () {
        this.menuData = this.davMenuData;
        this.getMemory();
        this.davMenuData.forEach(e=>{
            if(sessionStorage.getItem('type') == e.type){
                e.status = 1;
            }else{
                e.status = 0;
            }
        })
    },
    methods: {
         // 获取用户网盘使用情况
        async getMemory(){
            var {data} = await this.$https.post('member/Memory',{})
            this.data = data;
            if(data.rate){
                this.width = data.rate
            }
        }
    }
}
</script>
<style lang="less" scoped>
@import url(../../assets/css/common/leftmenu.less);
</style>


